<?php
header('Content-Type:text/html; Charset=UTF-8');
require 'lib/checker.php';


@$did = $_REQUEST['did'];



require 'lib/db.php';

@$desks = dbSelectAll('select id,name from desk order by id asc');

@$entrys = dbSelectAll('select id,name,imgUrl,price,type_id from entry order by id asc');

@$selDesk = dbSelect('select id,name from desk where id=:id',array('id'=>$did));

@$objects = dbSelectAll('select id,entry_id from object where desk_id=:did',array('did'=>$did));


require 'lib/header.php';

?>
    	<div class="container">
    		<div class="row">
    			<div class="col-xs-2">
    				<div class="form-group">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="搜索">
                            <div class="input-group-addon btn btn-default">
                                <span class="glyphicon glyphicon-search"></span>
                            </div>
                        </div>
                    </div>
    				<div class="panel panel-primary">
    					<div class="panel-heading">
    						<h4 class="panel-title"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;餐桌列表</h4>
    					</div>
    					<div class="panel-body">
    						<div class="list-group text-center">
			    				<?php foreach($desks as $desk){ ?>
		    						<a href="main.php?did=<?php echo $desk['id']; ?>" class="list-group-item"><?php echo $desk['name']; ?></a>
		    					<?php } ?>
		    				</div>
    					</div>
    				</div>
    			</div>
    			<div class="col-xs-10">
    				<?php if(!empty($mes)){ ?>
    					<div class="alert alert-danger">
    						<span class="close" data-dismiss="alert">&times;</span>
    						<?php echo $mes; ?>
    					</div>
    				<?php } ?>
    				<?php if(!empty($did)){ ?>
    					<div class="panel panel-primary">
	    					<div class="panel-heading">
	    						<div class="panel-title">
	    							<span class="glyphicon glyphicon-check"></span>&nbsp;餐桌[<?php echo $selDesk['name']; ?>]--已选菜品
	    							<button class="btn btn-success btn-xs pull-right"> 结账<span class="badge">6元</span></button>
	    						</div>
	    					</div>
	    					<div class="panel-body">
	    						<div class="row">
	    							<?php  foreach($objects as $object){ ?>
	    								<?php $entry = dbSelect('select id,name,imgUrl,price,type_id from entry where id=:id',array('id'=>$object['entry_id'])); ?>
	    								<?php @$type = dbSelect('select name from type where id=:id',array('id'=>$entry['type_id'])); ?>
		    							<div class="col-xs-2">
		    								<div class="thumbnail">
		    									<img src="imgs/<?php echo $entry['imgUrl']; ?>" />
		    									<div class="caption text-center">
		    										<h4 class="modal-title"><?php echo $entry['name']; ?></h4>
		    										<h5>
		    											<?php echo $entry['price']; ?>元&nbsp;[<?php echo $type['name']; ?>]
		    										</h5>
		    										<h5>
		    											<a href="dltdish.php?id=<?php echo $object['id']; ?>&did=<?php echo $did; ?>" class="btn btn-danger">取消</a>
		    										</h5>
		    									</div>
		    								</div>
		    							</div>
	    							<?php  } ?>
	    						</div>
	    					</div>
	    				</div>
    				<?php } ?>
    				<div class="panel panel-primary">
    					<div class="panel-heading ">
    						<div class="panel-title"><span class="glyphicon glyphicon-edit"></span>&nbsp;可选菜品
	    						<div class="col-xs-4 pull-right">
	                                <div class="form-group form-inline">
	                                     <div class="input-group ">
	                                        <input type="text" class="form-control" placeholder="搜索">
	                                        <div class="input-group-addon btn btn-default">全部<span class="caret"></span></div>
	                                        <div class="input-group-addon btn btn-default">
	                                             <span class="glyphicon glyphicon-search"></span>
	                                        </div>
	                                    </div>
	                                </div>
	                            </div>
                            </div>
    					</div>
    					<div class="panel-body">
    						<div class="row">
    							<?php  foreach($entrys as $entry){ ?>
    								<?php @$type = dbSelect('select name from type where id=:id',array('id'=>$entry['type_id'])); ?>
	    							<div class="col-xs-3">
	    								<div class="thumbnail">
	    									<img src="imgs/<?php echo $entry['imgUrl']; ?>" />
	    									<div class="caption text-center">
	    										<h4 class="modal-title"><?php echo $entry['name']; ?></h4>
	    										<h5>
	    											<?php echo $entry['price']; ?>元&nbsp;[<?php echo $type['name']; ?>]
	    										</h5>
	    										<h5>
	    											<a href="order.php?did=<?php echo $did; ?>&eid=<?php echo $entry['id']; ?>" class="btn btn-primary">点菜</a>
	    										</h5>
	    									</div>
	    								</div>
	    							</div>
    							<?php  } ?>
    						</div>
    					</div>
    				</div>
    			</div>
    		</div>
    	</div>
     </body>
 </html>